#include<stdio.h>
#include<malloc.h>
#include<string.h>
#include<string>
void * str[5];

int main(){
    int a=1;
    printf("Before malloc()s.\n");
    getchar();

    str[0]=malloc(1024*8);
    str[1]=malloc(1024*8);
    str[2]=malloc(1024*8);
    str[3]=malloc(1024*8);    
    str[4]=malloc(1024*8);

    FILE * fp=fopen("./text.txt", "r");
    if(!fp){
        printf("Open failed!");
        return 0;
    };

    fread(str[0],1,sizeof(str[]),fp);
    fread(str[1],1,sizeof(str[1]),fp);
    fread(str[2],1,sizeof(str[2]),fp);
    fread(str[3],1,sizeof(str[3]),fp);
    fread(str[4],1,sizeof(str[4]),fp);
    printf("The value where str[1] stored can be read now: %s\n", str[1]);
    printf("The value where str[3] stored can be read now: %s\n", str[3]);

    printf("After 5 malloc()s.\n");
    getchar();

    free(str[1]);
    free(str[3]);

    printf("After 2 free()s.\n");
    getchar();

    printf("The value where str[1] stored can be read now: %s\n", str[1]);
    printf("The value where str[3] stored can be read now: %s\n", str[3]);

    fclose(fp);
    free(str[0]);
    free(str[2]);
    free(str[4]);
    return 0;
}